package 字节;

import java.util.LinkedList;
import java.util.List;

public class 全排列 {
    List<List<Integer>> res=new LinkedList<>();
    public List<List<Integer>> permute(int[] nums) {
       List<Integer> track=new LinkedList<>();

        back(nums,track);
        return res;
    }
      void back(int[] nusms,List<Integer> track){
        if(track.size()==nusms.length){
            res.add(new LinkedList(track));
            return;
        }
        for (int i=0;i<nusms.length;i++){
            if(track.contains(nusms[i])) continue;
            track.add(nusms[i]);
            back(nusms,track);
            track.remove(track.size()-1);
        }
      }

      void beck(int[] nums,List<Integer> track){
        if(track.size()==nums.length){
            res.add(new LinkedList<>(track));
        }

        for(int i=0;i<nums.length;i++){
            if(track.contains(nums[i])) continue;
            track.add(nums[i]);
            back(nums,track);
            track.remove(track.size()-1);
        }
      }
}
